package com.atsansan.mywork.login.controller;

import com.atsansan.mywork.login.entity.BookEntity;
import com.atsansan.mywork.login.pachong.Info;
import com.atsansan.mywork.login.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author sansan
 * @create 2021-04-09 22:08
 */
@Controller
@RequestMapping("book")
public class BookPaChongController {



    @RequestMapping("/pa")
    public String paChong(@RequestParam("bname")String url, Map<String,Object> map)  {


        List<BookEntity> bookEntities = null;
        try {
            bookEntities = Info.getBook(url);
        } catch (IOException e) {
            e.printStackTrace();
            return "redirect:/error2";
        }
        System.out.println(bookEntities.size()+"###########################");
        map.put("bookEntities",bookEntities);

        return "select";


//        for (BookEntity bookEntity:bookEntities){
//
//            bookService.save(bookEntity);
//        }

//        for (int i = 0; i <bookEntities.size() ; i++) {
//            baseMapper.insert(bookEntities.get(i));
//
//        }





    }
}
